home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 7 / PC World Interactive 7.iso / program / ctutor.exe / SOURCE / READGOOD.C < prev    next >
C/C++ Source or Header  |  1994-05-15  |  622b  |  42 lines

  1.                             /* Chapter 10 - Program 5 - READGOOD.C */
  2. #include "stdio.h"
  3.  
  4. void main()
  5. {
  6. FILE *fp1;
  7. char oneword[100];
  8. char c;
  9.  
  10.    fp1 = fopen("TENLINES.TXT", "r");
  11.  
  12.    do {
  13.       c = fscanf(fp1, "%s", oneword); /* get one word from file    */
  14.       if (c != EOF)
  15.          printf("%s\n", oneword);     /* display it on the monitor */
  16.    } while (c != EOF);                /* repeat until EOF          */
  17.  
  18.    fclose(fp1);
  19. }
  20.  
  21.  
  22.  
  23. /* Result of execution
  24.  
  25. This
  26. is
  27. an
  28. example
  29. line.
  30. Line
  31. number
  32. 1
  33. This
  34. is
  35.  ... (Many other lines.) ...
  36. Additional
  37. lines.
  38. Additional
  39. lines.
  40.  
  41. */
  42.